var a = getApp(), t = a.require("utils/util.js"), o = a.require("utils/api.js"), n = 0, e = {
    Logs: []
};

Page({
    data: {
        modalType: "none",
        buttonEnabled: !1,
        model: {}
    },
    onLoad: function(a) {
        n = 0, this.loadData(a);
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.lastPage || this.loadData({
            pageIndex: ++n
        });
    },
    onShareAppMessage: function() {},
    loadData: function() {
        var t = this;
        o.userWithdrawPrepare({
            pageIndex: n
        }, function(o) {
            if (0 == n) e = o; else for (var i in o.Logs) e.Logs.push(o.Logs[i]);
            t.setData({
                lastPage: o.Logs.length < a.pageSize,
                model: e
            });
        });
    },
    onQuestionTap: function() {
        this.setData({
            modalType: "explain"
        });
    },
    onModalConfirm: function() {
        this.setData({
            modalType: "none"
        });
    },
    onWithdrawSubmit: function(a) {
        var n = parseFloat(a.detail.value.money);
        if (n > e.MoneyUsable) t.toast("可提现金额不足"); else if (n < e.MoneyMinWithdraw) t.toast("单次提现金额必须大于" + e.MoneyMinWithdraw + "元"); else {
            var i = this;
            wx.showModal({
                title: "提现确认",
                confirmColor: "#3bbb8d",
                content: "提现金额将直接到达你的微信余额中，确定提现？",
                success: function(t) {
                    t.confirm && (o.userSaveFormId({
                        formId: a.detail.formId
                    }), o.userWithdraw({
                        money: n
                    }, function() {
                        i.loadData();
                    }));
                }
            });
        }
    },
    onMoneyInput: function(a) {
        var t = parseFloat(a.detail.value);
        this.setData({
            buttonEnabled: a.detail.value && a.detail.value.length && NaN != t && t > 0
        });
    }
});